package com.daohang361.imqq.pugin.decoder;

import com.daohang361.imqq.Asycore.QQUser;
import com.daohang361.imqq.decoder.InterfaceDecoder;
import com.daohang361.imqq.tool.MyByteReciveArray;
import com.daohang361.imqq.tool.MyUtil;

/** 
 * @author naner E-mail:likun3344@163.com 
 * @create time：2011-6-8 下午08:48:27 
 */
public class Decoder2E implements InterfaceDecoder{
	public MyByteReciveArray myArray;
	public QQUser sessionQQ;
	public byte[] decryptAll=null;
	@Override
	public void init(MyByteReciveArray myArray, QQUser sessionQQ) {
		this.myArray=myArray;
		this.sessionQQ=sessionQQ;
	}
	@Override
	public QQUser decode() throws Exception {
		System.out.println("I'M Pugin Decoder2E");
		myArray.extract(0, 4);
		myArray.decryptRemain(sessionQQ.getAttr("imgKey"));
		byte[] token_data_2E=myArray.extract(0, 3);
		byte[] length_2E=myArray.extract(0, 3);
		byte[] index_2E=myArray.extractAll();//剩余的都算接下来发送包序列
		sessionQQ.addAttr("token_data_2E",token_data_2E );
		sessionQQ.addAttr("length_2E",length_2E );
		sessionQQ.addAttr("index_2E",index_2E );
		System.out.println("(MyUtil.bytes2Integer(index_2E):"
				+MyUtil.bytes2Integer(index_2E));
		if(MyUtil.bytes2Integer(index_2E)==0){
			sessionQQ.setCommand(0x031C);//
		}else {
			sessionQQ.setCommand(0x02b4);
		}
//		sessionQQ.setCommand(0);
		return sessionQQ;
	}
	
	/**
	 * 暴力打印
	 */
	public void violence()
	{
		//new ViolenceBytes(decryptAll).violence();
	}

	@Override
	public Object invoke(Object... o) {
		// TODO Auto-generated method stub
		return null;
	}
}
